#lang racket

(define (length a-list)
  (cond
    [(empty? (rest a-list)) 1]
    [else (+ 1  (length (rest a-list)))])
  )

(define (check-range temperature-list space-list)
  (cond
    [(not (= (length space-list) 2)) 
     (error 'check-range "check-range invalid parameter!")]
    [else (cond
            [(empty? temperature-list) true]
            [(and (in-space? (first temperature-list) (first-val space-list) (second space-list)
                  )
                  (check-range (rest temperature-list) space-list)
            ) true]
            [else false]
          )
     ]
    )
  )

(define (in-space? value lower upper)
  (cond
    [(and (>= value lower) 
          (<= value upper)) true]
    [else false])
  )

(define (first-val space-list)
  (first space-list)
  )

(define (second-val space-list)
  (first-val (rest space-list))
  )


; Test

(define temp-list
  (cons 65
    (cons 70
      (cons 75
        (cons 45
          (cons 90 empty))))))

(define a-space-list
  (cons 50
    (cons 90 empty)))

(in-space? 45 50 90)

(check-range temp-list a-space-list)
